package com.rqf.mr.controller;

import java.util.List;
import java.util.Map;
import java.util.concurrent.CountDownLatch;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.aspectj.bridge.IMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import com.rqf.mr.service.ILoginService;
import com.rqf.mr.service.IMessageService;
import com.server.web.JSONSerielizer;
import com.server.web.OutputUtil;

@Controller
@RequestMapping("message")
public class MessageController {
	
	@Autowired
	private IMessageService messageService;
	
	private int Count = 0;
	
	@RequestMapping("byNurseId/{loginName}")
	public void login(HttpServletRequest request, 
			HttpServletResponse response,@PathVariable String loginName){
		List<Map<String, Object>> list = messageService.getPatiNameByNurseId(loginName);
		Count++;
		System.out.println("消息推送--"+loginName+"--请求成功！！！！！"+Count);
		String json = JSONSerielizer.toJson(list, null, null);
		OutputUtil.returnJsonp(request, response, json);
	}
	
	@RequestMapping("add/{ordId}")
	public void add(HttpServletRequest request, 
			HttpServletResponse response,@PathVariable String ordId){
		Boolean result = false;
		result = messageService.messageAdd(ordId);
		OutputUtil.returnJsonp(request, response, result.toString());
	}
	
}
